package com.geetour.columbus.region.dao.impl;

import java.util.List;

import com.geetour.columbus.common.exceptions.DAOException;
import com.geetour.columbus.common.model.R.CityPage;
import com.geetour.columbus.core.ibatis.SqlMapClientDaoSupportEx;
import com.geetour.columbus.region.dao.ICityPageDAO;

public class CityPageDAOImpl extends SqlMapClientDaoSupportEx implements ICityPageDAO {

    @Override
    public void insertCityPage(CityPage city) throws DAOException {
        this.insert("insertCityPage", city);
    }

    @Override
    public int insertCityPageBatch(List<CityPage> cityList) throws DAOException {
        if (cityList == null || cityList.isEmpty()) {
            return -1;
        }
        return this.insert("insertCityPage", cityList);
    }

    @Override
    public int updateCityPage(CityPage city) throws DAOException {
        if (city == null) {
            return -1;
        }
        return this.update("updateCityPage", city);
    }

    @Override
    public int deleteCityPage(Long id) throws DAOException {
        if (id == null) {
            return -1;
        }
        return this.delete("deleteCityPage", id);
    }

    @Override
    public CityPage findCityPageById(Long id) throws DAOException {
        if (id == null) {
            return null;
        }
        return (CityPage) this.queryObject("findCityPageById", id);
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<CityPage> findAllCityPages() throws DAOException {
        return (List<CityPage>) this.queryList("findAllCityPages", null);
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<CityPage> findCityPages(CityPage city) throws DAOException {
        if (city == null) {
            return null;
        }
        return (List<CityPage>) this.queryList("findCityPages", city);
    }
}
